package com.cuanbo.dualscreenteachfu.activity;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.cuanbo.dualscreenteachfu.R;
import com.cuanbo.dualscreenteachfu.base.LHBaseActivity;

/**
 *设备控制
 */
public class DevControlActivity extends LHBaseActivity {
    private View rootView;
    private TextView tvSk;
    private TextView tvXk;
    private TextView tvComputState;
    private ImageView ivComput;
    private ImageView ivComputSw;
    private boolean comput;
    private TextView tvProjectionState;
    private ImageView ivProjection;
    private ImageView ivProjectionSw;
    private boolean projection;
    private TextView tvScreenClothState;
    private ImageView ivScreenCloth;
    private ImageView ivScreenClothSw;
    private boolean screenCloth;
    private TextView tvAirState;
    private ImageView ivAir;
    private ImageView ivAirSw;
    private boolean air;
    private TextView tvLight1State;
    private ImageView ivLight1;
    private ImageView ivLight1Sw;
    private boolean light1;
    private TextView tvLight2State;
    private ImageView ivLight2;
    private ImageView ivLight2Sw;
    private boolean light2;
    private TextView tvLight3State;
    private ImageView ivLight3;
    private ImageView ivLight3Sw;
    private boolean light3;
    private TextView tvCurtain;
    private ImageView ivCurtain;
    private ImageView ivCurtainSw;
    private boolean curtain;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        rootView= LayoutInflater.from(this).inflate(R.layout.activity_devcontrol,null);
        setContentView(rootView);
        init();
    }

    public void init(){
        initView();
    }

    public void initView() {
        tvSk = rootView.findViewById(R.id.tvSk);
        tvXk = rootView.findViewById(R.id.tvXk);
        tvComputState = rootView.findViewById(R.id.tvComputState);
        ivComput = rootView.findViewById(R.id.ivComput);
        ivComputSw = rootView.findViewById(R.id.ivComputSw);
        tvProjectionState = rootView.findViewById(R.id.tvProjectionState);
        ivProjection = rootView.findViewById(R.id.ivProjection);
        ivProjectionSw = rootView.findViewById(R.id.ivProjectionSw);
        tvScreenClothState = rootView.findViewById(R.id.tvScreenClothState);
        ivScreenCloth = rootView.findViewById(R.id.ivScreenCloth);
        ivScreenClothSw = rootView.findViewById(R.id.ivScreenClothSw);
        tvAirState = rootView.findViewById(R.id.tvAirState);
        ivAir = rootView.findViewById(R.id.ivAir);
        ivAirSw = rootView.findViewById(R.id.ivAirSw);
        tvLight1State = rootView.findViewById(R.id.tvLight1State);
        ivLight1 = rootView.findViewById(R.id.ivLight1);
        ivLight1Sw = rootView.findViewById(R.id.ivLight1Sw);
        tvLight2State = rootView.findViewById(R.id.tvLight2State);
        ivLight2 = rootView.findViewById(R.id.ivLight2);
        ivLight2Sw = rootView.findViewById(R.id.ivLight2Sw);
        tvLight3State = rootView.findViewById(R.id.tvLight3State);
        ivLight3 = rootView.findViewById(R.id.ivLight3);
        ivLight3Sw = rootView.findViewById(R.id.ivLight3Sw);
        tvCurtain = rootView.findViewById(R.id.tvCurtain);
        ivCurtain = rootView.findViewById(R.id.ivCurtain);
        ivCurtainSw = rootView.findViewById(R.id.ivCurtainSw);
    }
    
    @Override
    public void requestData() {
        
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    /**
     *返回
     */
    public void btnBack(View v) {

        finish();
    }

    /**
     *电脑
     */
    public void btnComput(View v) {
        comput=!comput;
        if(comput){
            tvComputState.setText("ON");
            tvComputState.setTextColor(0xff637abe);
            ivComput.setImageResource(R.drawable.device_computer);
            ivComputSw.setImageResource(R.drawable.switch_on2x);
        }else{
            tvComputState.setText("OFF");
            tvComputState.setTextColor(0xff98a9c5);
            ivComput.setImageResource(R.drawable.device_computer_off);
            ivComputSw.setImageResource(R.drawable.switch_off2x);
        }
    }

    /**
     *投影
     */
    public void btnProjection(View v) {
        projection=!projection;
        if(projection){
            tvProjectionState.setText("ON");
            tvProjectionState.setTextColor(0xff637abe);
            ivProjection.setImageResource(R.drawable.device_projection);
            ivProjectionSw.setImageResource(R.drawable.switch_on2x);
        }else{
            tvProjectionState.setText("OFF");
            tvProjectionState.setTextColor(0xff98a9c5);
            ivProjection.setImageResource(R.drawable.device_projection_off);
            ivProjectionSw.setImageResource(R.drawable.switch_off2x);
        }
    }

    /**
     *幕布
     */
    public void btnScreenCloth(View v) {
        screenCloth=!screenCloth;
        if(screenCloth){
            tvScreenClothState.setText("ON");
            tvScreenClothState.setTextColor(0xff637abe);
            ivScreenCloth.setImageResource(R.drawable.device_c);
            ivScreenClothSw.setImageResource(R.drawable.switch_on2x);
        }else{
            tvScreenClothState.setText("OFF");
            tvScreenClothState.setTextColor(0xff98a9c5);
            ivScreenCloth.setImageResource(R.drawable.device_c_off);
            ivScreenClothSw.setImageResource(R.drawable.switch_off2x);
        }
    }

    /**
     *空调
     */
    public void btnAir(View v) {
        air=!air;
        if(air){
            tvAirState.setText("ON");
            tvAirState.setTextColor(0xff637abe);
            ivAir.setImageResource(R.drawable.device_aircondition);
            ivAirSw.setImageResource(R.drawable.switch_on2x);
        }else{
            tvAirState.setText("OFF");
            tvAirState.setTextColor(0xff98a9c5);
            ivAir.setImageResource(R.drawable.device_aircondition_off);
            ivAirSw.setImageResource(R.drawable.switch_off2x);
        }
    }

    /**
     *灯光一
     */
    public void btnLight1(View v) {
        light1=!light1;
        if(light1){
            tvLight1State.setText("ON");
            tvLight1State.setTextColor(0xff637abe);
            ivLight1.setImageResource(R.drawable.device_lighting);
            ivLight1Sw.setImageResource(R.drawable.switch_on2x);
        }else{
            tvLight1State.setText("OFF");
            tvLight1State.setTextColor(0xff98a9c5);
            ivLight1.setImageResource(R.drawable.device_lighting_off);
            ivLight1Sw.setImageResource(R.drawable.switch_off2x);
        }
    }

    /**
     *灯光二
     */
    public void btnLight2(View v) {
        light2=!light2;
        if(light2){
            tvLight2State.setText("ON");
            tvLight2State.setTextColor(0xff637abe);
            ivLight2.setImageResource(R.drawable.device_lighting);
            ivLight2Sw.setImageResource(R.drawable.switch_on2x);
        }else{
            tvLight2State.setText("OFF");
            tvLight2State.setTextColor(0xff98a9c5);
            ivLight2.setImageResource(R.drawable.device_lighting_off);
            ivLight2Sw.setImageResource(R.drawable.switch_off2x);
        }
    }

    /**
     *灯光三
     */
    public void btnLight3(View v) {
        light3=!light3;
        if(light3){
            tvLight3State.setText("ON");
            tvLight3State.setTextColor(0xff637abe);
            ivLight3.setImageResource(R.drawable.device_lighting);
            ivLight3Sw.setImageResource(R.drawable.switch_on2x);
        }else{
            tvLight3State.setText("OFF");
            tvLight3State.setTextColor(0xff98a9c5);
            ivLight3.setImageResource(R.drawable.device_lighting_off);
            ivLight3Sw.setImageResource(R.drawable.switch_off2x);
        }
    }

    /**
     *窗帘
     */
    public void btnCurtain(View v) {
        curtain=!curtain;
        if(curtain){
            tvCurtain.setText("ON");
            tvCurtain.setTextColor(0xff637abe);
            ivCurtain.setImageResource(R.drawable.device_curtain);
            ivCurtainSw.setImageResource(R.drawable.switch_on2x);
        }else{
            tvCurtain.setText("OFF");
            tvCurtain.setTextColor(0xff98a9c5);
            ivCurtain.setImageResource(R.drawable.device_curtain_off);
            ivCurtainSw.setImageResource(R.drawable.switch_off2x);
        }
    }
}